﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;

namespace GUI
{
    public partial class frmLichGiao : Form
    {
        public int sodh;
        public frmLichGiao()
        {
            InitializeComponent();
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            txtSoDH.Text = DemDHTuLG(txtNgayGiao.Value).ToString();
            LayDHTuLG(txtNgayGiao.Value);
            

        }
        void LayDSLichGiao()
        {
            List<LichGiaoDTO> ds = new List<LichGiaoDTO>();
            LichGiaoBUS bus = new LichGiaoBUS();
            ds = bus.LayDSLichGiao();
            int stt = 1;
            dgvDanhSach.Rows.Clear();
            sodh = ds.Count();
            for (int i = 0; i < ds.Count(); i++)
            {
                dgvDanhSach.Rows.Add(stt, ds[i].MaDH, ds[i].NgayGioDH, ds[i].NgayGioGH);
                stt++;
            }
        }

        private void frmLichGiao_Load(object sender, EventArgs e)
        {
            LayDSLichGiao();
            txtSoDH.Text = sodh.ToString();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        void LayDHTuLG(DateTime day)
        {
            List<LichGiaoDTO> ds = new List<LichGiaoDTO>();
            LichGiaoBUS bus = new LichGiaoBUS();
            ds = bus.LayDHTuLG(day);
            int stt = 1;
            dgvDanhSach.Rows.Clear();
            for (int i = 0; i < ds.Count; i++)
            {
                dgvDanhSach.Rows.Add(stt,ds[i].MaDH,ds[i].NgayGioDH,ds[i].NgayGioGH);
                stt++;
            }

        }
        int DemDHTuLG(DateTime day)
        {
            int kq = 0;
            LichGiaoBUS bus = new LichGiaoBUS();
            kq = bus.DemDHTuLG(day);
            return kq;
        }

        private void btnQuayLai_Click(object sender, EventArgs e)
        {
            this.frmLichGiao_Load(sender,e);
        }

       
    }
}
